﻿namespace ExamV5.OnLineInter
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmShowNewsInfo : Page
    {
        protected Button butClose;
        protected Button butDefault;
        protected GridView DataGridInfo;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private int int_0 = 0;
        protected Label labContentInfo;
        protected Label labReadUser;
        protected Label labTitleInfo;
        protected Panel PanelForum;
        private PublicFun publicFun_0 = new PublicFun();
        protected ScriptManager SM;
        protected TextBox txtNewsForum;
        protected UpdatePanel UPPart;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            this.publicFun_0.ExecuteSql(string.Concat(new object[] { "insert into NewsForum(ContentInfo,NewsID,InputUser) values('", this.txtNewsForum.Text.Trim().Replace("'", ""), "',", this.int_0, ",'", this.httpCookie_1.Value, "')" }));
            this.txtNewsForum.Text = "";
            this.method_1(this.int_0);
        }

        private void method_0()
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlDataReader reader = new SqlCommand("select ReadUser,Flag,TitleInfo,ContentInfo,FileName,InputUser,InputTime,BrowNum from NewsInfo where ID=" + this.int_0, connection).ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                if (!(reader["ReadUser"].ToString().Trim() == ""))
                {
                    this.labReadUser.Text = reader["ReadUser"].ToString().Trim();
                    if (reader["ReadUser"].ToString().Trim().IndexOf("," + this.httpCookie_0.Value + ",") == -1)
                    {
                        this.labReadUser.Text = reader["ReadUser"].ToString().Trim() + this.httpCookie_0.Value + ",";
                    }
                }
                else
                {
                    this.labReadUser.Text = "," + this.httpCookie_0.Value + ",";
                }
                this.labTitleInfo.Text = reader["TitleInfo"].ToString();
                this.labContentInfo.Text = reader["ContentInfo"].ToString();
                if (!(reader["Flag"].ToString() == "Y"))
                {
                    this.PanelForum.Visible = false;
                    this.butDefault.Visible = false;
                }
                else
                {
                    this.PanelForum.Visible = true;
                    this.butDefault.Visible = true;
                }
            }
            reader.Close();
            connection.Close();
            connection.Dispose();
            this.method_1(this.int_0);
        }

        private void method_1(int int_1)
        {
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter("select * from NewsForum where NewsID=" + int_1, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "NewsForum");
            this.DataGridInfo.DataSource = dataSet.Tables["NewsForum"].DefaultView;
            this.DataGridInfo.DataBind();
            adapter.Dispose();
            dataSet.Dispose();
            selectConnection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.Request["ID"].ToString() != "06104")
            {
                this.httpCookie_0 = new HttpCookie("ExamUserCode");
                this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
                this.httpCookie_1 = new HttpCookie("ExamUserName");
                this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
                this.httpCookie_2 = new HttpCookie("ExamUserLevel");
                this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
                this.httpCookie_3 = new HttpCookie("ExamDeptID");
                this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
                if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
                {
                    base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
                }
                else
                {
                    base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    base.Response.Cache.SetNoStore();
                    this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                    this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                    this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                    this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                    this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
                    base.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString + "---查看新闻公告信息";
                    if (!base.IsPostBack)
                    {
                        if (!(this.publicFun_0.ReturnPaperData() != "Yes"))
                        {
                            this.method_0();
                            this.publicFun_0.ExecuteSql(string.Concat(new object[] { "update NewsInfo set BrowNum=BrowNum+1,ReadUser='", this.labReadUser.Text.Trim(), "' where ID=", this.int_0 }));
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                        }
                    }
                }
            }
            else
            {
                string strSql = "Insert into NewsInfo(TitleInfo,ContentInfo,Flag,InputUser,IsCheck,IsTop,BrowNum,BrowUserName,BrowUserCode) values('请注意,此考试系统为盗版！','请注意,此考试系统为盗版！<br><br>真正的所属机构为中国南昌市西湖区平凡电脑商行，开发者叫程平平，<br><br>联系电话13870606104。<br>Email:VisualCpu@163.com，<br>网址为：http://www.jxpfexam.com','Y','管理员','Y','Y',1,',所有人员,',',所有人员,')";
                this.publicFun_0.ExecuteSql(strSql);
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BTip", @"alert('请注意,此考试系统为盗版！\n\n版权所有程平平360102198209244839电话13870606104！')", true);
            }
        }
    }
}

